<template>
  <div class="duty-car-dialog">
    <antd-form :options="formOptions" @submit="filterFormData = $event" />
    <common-table
      ref="table"
      :fetch="getGridResourceDataAsync"
      :fetch-params="gridResourceDataParams"
      :columns="columns"
      class="people-table"
      :showToolbar="false"
      @vue:mounted="() => $refs.table.load()"
    >
      <template #index="{ text, scope, index }">
        <span>{{ index + 1 }}</span>
      </template>
      <template #action="{ text, scope }">
        <span style="color: #3f8eee; cursor: pointer" @click="details(scope)">详情</span>
      </template>
    </common-table>
  </div>
</template>

<script>
import AntdForm from '@gis/lib/components/antd-form/index.js';
import { useUserInfoStore } from '@gis/lib/pinia/userInfo.js';

export default {
  name: 'duty-car-dialog',
  components: { AntdForm },
  props: {},
  data() {
    return {
      filterFormData: { license_plate_number: '' },
      formOptions: [
        {
          component: 'a-input',
          label: '车牌号',
          field: 'license_plate_number',
        },
      ],
      columns: [
        {
          title: '所属单位',
          dataIndex: 'unit_name',
        },
        {
          title: '车牌号',
          dataIndex: 'license_plate_number',
        },
        {
          title: '车辆类型',
          dataIndex: 'type_code',
          width: 140,
          align: 'center',
        },
        {
          title: '设备序列号',
          dataIndex: 'equipment_identification',
        },
        {
          title: '使用队伍',
          dataIndex: 'team_name',
        },
        // {
        //   title: "操作",
        //   scopedSlots: { customRender: "action" },
        //   width: 80,
        //   align: "center",
        // },
      ],
    };
  },
  computed: {
    areaCode() {
      const { area_code } = useUserInfoStore();
      return area_code;
    },
    basicParams() {
      return {
        area_code: this.areaCode,
      };
    },
    gridResourceDataParams() {
      return Object.assign({}, this.basicParams, this.filterFormData);
    },
  },
  methods: {
    async getGridResourceDataAsync(params) {
      if (!params) return;
      const res = await this.$axios.get('/xw-microservice/xw-command-dispatch/v3/zz/car/page', {
        params: Object.assign({}, params),
      });
      return { data: res.data.list, total: res.data.count };
    },
    details() {},
  },
};
</script>

<style scoped lang="less">
.duty-car-dialog {
  padding: 10px 10px 0;
}
</style>
